<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="/Templates/Template.xhtml">

	<ui:define name="contenu">

		<c:choose>
			<c:when test="#{loginBean.exist()}">

				<h:form id="AjoutI">

				</h:form>
				<br />

				<h:form id="a">
					<p:growl id="growl" showDetail="true" sticky="true" life="4000" />
					<p:dataTable var="medecin" value="#{medecinBean.medecins}"
						filteredValue="#{patientTableBean.filtredmedecins}" id="AjoutTab"
						widgetVar="medecinTable" paginatorPosition="bottom"
						emptyMessetat="medecin non trouvé" paginator="true" rows="10"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15" sortMode="multiple"
						style="width:900px;font-size:14px;font-weight:400;">

						<f:facet name="header">
							<p:outputPanel>
								<h:outputText value="Recherche:" />
								<p:inputText id="globalFilter" onkeyup="medecinTable.filter()"
									style="width:80px;" />
									<c:if test="#{loginBean.e.libelle=='Administrateur'}">
								<p:commandButton value="&nbsp;Ajouter une medecin"
									style="float:right;height:30px" image="ui-icon-circule-plus"
									actionListener="#{medecinBean.ajoutEvent()}"
									update=":edit:editP" oncomplete="medecinAjout.show()" />
									</c:if>
							</p:outputPanel>
						</f:facet>

						<p:column id="medecinId" headerText="ID" sortBy="#{medecin.id}">

							<h:outputText value="#{medecin.id}" />


						</p:column>
						<p:column headerText="Nom" id="medecinNom"
							filterBy="#{medecin.nom}" filterMatchMode="contains">

							<h:outputText value="#{medecin.nom}" />

						</p:column>
						<p:column headerText="Prenom" id="medecinPrenom"
							filterBy="#{medecin.prenom}" filterMatchMode="contains">
							<h:outputText value="#{medecin.prenom}" />
						</p:column>
						<p:column headerText="Etat Civil" id="medecinetat">
							<h:outputText value="#{medecin.etatcivil}" />
						</p:column>
						<p:column headerText="Telephone" id="medecintel">
							<h:outputText value="#{medecin.tel}" />
						</p:column>
						<p:column headerText="Specialite" id="medecinsp" filterBy="#{medecin.specialite.noms}" filterMatchMode="contains">
							<h:outputText value="#{medecin.specialite.noms}" />
						</p:column>
					<c:if test="#{loginBean.e.libelle=='Administrateur'}">

						<p:column style="width:4%">
							<p:commandButton id="Editer" update=":Actualise:displaye"
								icon="ui-icon-arrowrefresh-1-w" oncomplete="medecinEdit.show();"
								actionListener="#{medecinBean.editEvent(medecin.id)}"
								title="Editer" />
						</p:column>
						<p:column style="width:4%">
							<p:commandButton id="Supprimer" icon="ui-icon-trash"
								update=":supp:confirmDialog" oncomplete="confirmation.show()"
								title="Supprime">
								<f:setPropertyActionListener value="#{medecin}"
									target="#{medecinBean.medecin}" />
							</p:commandButton>
						</p:column>
						</c:if>
					</p:dataTable>
				</h:form>

				<h:form id="edit">

					<p:dialog header="Ajout de medecin" widgetVar="medecinAjout"
						resizable="false" id="editP">

						<p:growl id="growledit" showDetail="true" sticky="true"
							life="2000" />
						<h:panelGrid id="display" columns="2" cellpadding="4"
							style="margin:0 auto;">


							<h:outputLabel value="" />
							<h:inputHidden value="#{medecinBean.medecin.id}" id="id"
								required="true" />


							<h:outputLabel for="nom" value="Nom:"
								style="color: black;font-weight: bold" />
							<p:inputText value="#{medecinBean.medecin.nom}" id="nom"
								required="true" requiredMessage="Nom" />
							<h:outputLabel for="prenom" value="Prenom:"
								style="color: black;font-weight: bold" />
							<p:inputText value="#{medecinBean.medecin.prenom}" id="prenom"
								required="true" requiredMessage="Prenom" />
							<h:outputLabel for="etat" value="Etat Civil :"
								style="color: black;font-weight: bold" />
							<h:outputLabel for="tel" value="Telehpone :"
								style="color: black;font-weight: bold" />
							<p:selectOneListbox id="etat"
								value="#{medecinBean.medecin.etatcivil}"
								requiredMessage="Etat Civil" required="true">
								<f:selectItem itemLabel="Marié(e)" itemValue="Marie" />
								<f:selectItem itemLabel="Celibataire" itemValue="Celibataire" />
							</p:selectOneListbox>
							<p:inputText value="#{medecinBean.medecin.tel}" id="tel" />

							<h:outputLabel for="Sexe" value="Sexe :"
								style="color: black;font-weight: bold" />
							<h:outputLabel for="Date" value="Date de naissance :"
								style="color: black;font-weight: bold" />
							<p:selectOneListbox id="Sexe" value="#{medecinBean.medecin.sexe}"
								requiredMessage="Sexe" required="true">
								<f:selectItem itemLabel="Homme" itemValue="Homme" />
								<f:selectItem itemLabel="Femme" itemValue="Femme" />
							</p:selectOneListbox>

							<p:calendar value="#{medecinBean.medecin.datenaissance}"
								id="Date" required="true" requiredMessage="Date de naissance" />


							<p:outputLabel for="Prestation" value="Prestation :"
								style="color: black;font-weight: bold" />
							<p:outputLabel value="Specialite :"
								style="color: black;font-weight: bold" />

							<p:inputText value="#{medecinBean.medecin.prestation}"
								id="Prestation" />

							<p:selectOneMenu id="Specialite"
								value="#{medecinBean.selectedSpecialite}" effect="drop">
								<f:selectItem itemLabel="Select One" itemValue="" />
								<f:selectItems value="#{specialiteBean.specialites}"
									var="specialite" itemLabel="#{specialite.noms}"
									itemValue="#{specialite.idspecialite}" />

							</p:selectOneMenu>
							<h:outputLabel for="Adresse" value="Adresse :"
								style="color: black;font-weight: bold" />

							<p:inputText value="#{medecinBean.medecin.adresse}" id="Adresse" />

						</h:panelGrid>
						<p:separator />
						<p:commandButton value="Enregistrer"
							update=":a:AjoutTab, :a:growl"
							actionListener="#{medecinBean.ajoutm()}"
							oncomplete="medecinAjout.hide()" />
					</p:dialog>

				</h:form>

				<h:form id="Actualise">

					<p:dialog header="Modification" widgetVar="medecinEdit"
						resizable="false" id="editPer">

						<p:growl id="growledit" showDetail="true" sticky="true"
							life="4000" />
						<h:panelGrid id="displaye" columns="2" cellpadding="4"
							style="margin:0 auto;">


							<h:outputLabel value="" for="id" />
							<h:inputHidden value="#{medecinBean.medecin.id}" id="id"
								required="true" />


							<h:outputLabel for="nom" value="Nom:"
								style="color: black;font-weight: bold" />
							<p:inputText value="#{medecinBean.medecin.nom}" id="nom"
								required="true" requiredMessage="Nom" />
							<h:outputLabel for="prenom" value="Prenom:"
								style="color: black;font-weight: bold" />
							<p:inputText value="#{medecinBean.medecin.prenom}" id="prenom"
								required="true" requiredMessage="Prenom" />
							<h:outputLabel for="etat" value="Etat Civil :"
								style="color: black;font-weight: bold" />
							<h:outputLabel for="tel" value="Telehpone :"
								style="color: black;font-weight: bold" />
							<p:selectOneListbox id="etat"
								value="#{medecinBean.medecin.etatcivil}"
								requiredMessage="Etat Civil" required="true">
								<f:selectItem itemLabel="Marié(e)" itemValue="Marie" />
								<f:selectItem itemLabel="Celibataire" itemValue="Celibataire" />
							</p:selectOneListbox>
							<p:inputText value="#{medecinBean.medecin.tel}" id="tel" />

							<h:outputLabel for="Sexe" value="Sexe :"
								style="color: black;font-weight: bold" />
							<h:outputLabel for="Date" value="Date de naissance :"
								style="color: black;font-weight: bold" />
							<p:selectOneListbox id="Sexe" value="#{medecinBean.medecin.sexe}"
								requiredMessage="Sexe" required="true">
								<f:selectItem itemLabel="Homme" itemValue="Homme" />
								<f:selectItem itemLabel="Femme" itemValue="Femme" />
							</p:selectOneListbox>

							<p:calendar value="#{medecinBean.medecin.datenaissance}"
								id="Date" required="true" requiredMessage="Date de naissance" />


							<p:outputLabel for="Prestation" value="Prestation :"
								style="color: black;font-weight: bold" />
							<p:outputLabel value="Specialite :"
								style="color: black;font-weight: bold" />

							<p:inputText value="#{medecinBean.medecin.prestation}"
								id="Prestation" />

							<p:selectOneMenu id="Specialite"
								value="#{medecinBean.selectedSpecialite}" effect="drop">

								<f:selectItems value="#{specialiteBean.specialites}"
									var="specialite" itemLabel="#{specialite.noms}"
									itemValue="#{specialite.idspecialite}" />

							</p:selectOneMenu>
							<h:outputLabel for="Adresse" value="Adresse :"
								style="color: black;font-weight: bold" />

							<p:inputText value="#{medecinBean.medecin.adresse}" id="Adresse" />

						</h:panelGrid>
						<p:separator />
						<p:commandButton value="Enregistrer"
							update=":a:AjoutTab, :a:growl"
							actionListener="#{medecinBean.edition()}"
							oncomplete="medecinEdit.hide()" />
					</p:dialog>

				</h:form>

				<h:form id="supp">

					<p:dialog id="confirmDialog" showEffect="fade"
						header="Suppression d'un Medecin" severity="alert"
						widgetVar="confirmation">
						<p:growl id="messages" showDetail="true" sticky="true" life="4000" />
						<h:inputHidden value="#{medecinBean.medecin.id}" id="supp"
							required="true" />
						<p:outputLabel
							value="Etes vous sûr de vouloir supprimer ce Medecin ?" />
						<p:commandButton id="confirm" value="Yes Sure"
							update="messages,:a:AjoutTab" oncomplete="confirmation.hide()"
							actionListener="#{medecinBean.delet()}" />
						<p:commandButton id="decline" value="Not Yet"
							onclick="confirmation.hide()" type="button" />

					</p:dialog>

				</h:form>
							</c:when>

			<c:otherwise>
			<script language="javascript"><!--
location.replace("Login.jsf")
//-->
</script>
				
			</c:otherwise>
		</c:choose>
	</ui:define>

</ui:composition>
</html>